#pragma once

#pragma pack(1)
typedef struct _JMPCODE
{
    BYTE jmp;
    DWORD addr;
}JMPCODE,*PJMPCODE;

typedef struct _UNJMPCODE
{
    BYTE jmp;
    DWORD addr;
}UNJMPCODE,*PUNJMPCODE;

bool InlineHook(LPVOID src_addr, LPVOID jmp_addr);
bool UnInlineHook(LPVOID src_addr );


#define SET_HOOK_FUNCTION_HD \
	     __asm	\
    {\
        __asm PUSH ebp \
        __asm mov ebp,esp \
        __asm PUSH esi\
    }

#define SET_HOOK_FUNCTION_END( org_addr , value) \
	 __asm \
    {\
        __asm pop esi \
        __asm mov ebx, org_addr \
        __asm add ebx,5 \
		__asm mov eax, DWORD PTR [bp+4]\
		__asm push eax\
        __asm call ebx \
		__asm pop eax \
    }

#define SET_INLINE_HOOK(fun_name, h_dll, dll_name, jmp_addr)\
	fun_name##Def pOrgFun = (fun_name##Def)GetProcAddress(h_dll, #fun_name); \
	if ( pOrgFun != NULL )\
    {\
		InlineHook(pOrgFun, jmp_addr);\
		nIndex++;\
	}